#include <elasticlient/client.h>
#include <cpr/cpr.h>
#include <exception>
#include <iostream>

int main()
{
    // 1.构建 ES 客户端
    elasticlient::Client client({"http://127.0.0.1:9200/"});
    // 2.发起搜索请求
    try {
        cpr::Response resp = client.search("user", "_doc", "{\"query\": { \"match_all\": {} }}");
        std::cout << resp.status_code << "\n";
        std::cout << resp.text << "\n";
    } catch (const std::exception& e) {
        std::cout << "请求失败: " << e.what() << '\n';
        return 1;
    }
    return 0;
}